package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.Detail;
import cn.wolfcode.wolf2w.repository.DetailRepository;
import cn.wolfcode.wolf2w.service.IDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("detailService")
public class DetailServiceImpl implements IDetailService {

    @Autowired
    private DetailRepository detailRepository;

    @Override
    public void save(Detail detail) {
        detail.setId(null);
        detailRepository.save(detail);
    }

    @Override
    public void update(Detail detail) {
        detailRepository.save(detail);
    }


    @Override
    public void delete(String id) {
        detailRepository.deleteById(id);
    }

    @Override
    public Detail get(String id) {
        Detail detail = detailRepository.findById(id).get();
        return detail;
    }

    @Override
    public List<Detail> list() {
        return detailRepository.findAll();
    }


}
